/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package leagueControllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JList;
import javax.swing.ListSelectionModel;
import leagueViews.Teams;

/**
 *
 * @author Seamus
 */
public class TeamController {
    private Teams teams;
    private ActionListener actionListener;
    public TeamController(Teams teams){
        this.teams = teams;
        fillTeamList();
    }
    
    public void control(){
        actionListener = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if(e.getSource() == teams.getCreateTeamBtn())
                    createTeam();
                else if(e.getSource() == teams.getViewTeamBtn())
                    viewTeam();
                else if(e.getSource() == teams.getUpdateTeamBtn())
                    updateTeam();
                else if(e.getSource() == teams.getDeleteTeamBtn())
                    deleteTeam();
                else if(e.getSource() == teams.getExitButton())
                    exit();
            }
        };
        teams.getCreateTeamBtn().addActionListener(actionListener);
        teams.getViewTeamBtn().addActionListener(actionListener);
        teams.getUpdateTeamBtn().addActionListener(actionListener);
        teams.getDeleteTeamBtn().addActionListener(actionListener);
        teams.getExitButton().addActionListener(actionListener);
        teams.getTeamList().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    
    public void fillTeamList(){
        
    }
    
    public void createTeam(){
        
    }
    
    public void viewTeam(){
        JList teamList = teams.getTeamList();
        teamList.getSelectedIndex();
        
    }
    
    public void updateTeam(){
        JList teamList = teams.getTeamList();
        teamList.getSelectedIndex();
    }
    
    public void deleteTeam(){
        JList teamList = teams.getTeamList();
        teamList.getSelectedIndex();
    }
    
    public void exit(){
        teams.dispose();
    }
}
